package com.xinyu.TestPackage;

import javax.servlet.ServletContext;

import org.apache.struts2.ServletActionContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.xinyu.entity.User;

public class TestAction extends ActionSupport {
	public String execute() throws Exception {
		ServletContext sContext = ServletActionContext.getServletContext();
		WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(sContext);
			User user = (User) webApplicationContext.getBean("user");
			System.out.println(user);
			ActionContext.getContext().put("user", user);
		return SUCCESS;
	}

}
